Many applications require a saw-tooth or triangular shaped waveforms whose parameters can be changed under program control, for example switched mode power supplies. To provide such waveforms in an application using a microcontroller, additional circuitry is necessary to be able to generate such waveforms. This is highly undesirable as it increases the costs and size of the respective application.